package caseManagerBusiness;

import easyDAO.SqlDispatch;
import impl.TestServerBusinessImpl;
import models.MyConfig;
import models.ReturnJson;
import models.SqlReturnModel;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by yangxianming on 2018/7/26.
 */
public class DelCase implements TestServerBusinessImpl {
    @Override
    public String doIt(HttpServletRequest request, MyConfig myConfig) {
        ReturnJson returnJson = new ReturnJson();
        //读取请求
        String caseId = request.getParameter("caseId");
        //数据组装
        String set = " `isdel`=\"1\" ";
        String where = "id=" + caseId;
        //数据库操作
        SqlDispatch sqlDispatch = new SqlDispatch(myConfig);
        SqlReturnModel sqlReturnModel = sqlDispatch.update("testcase", set, where);
        returnJson.setApiStatus((sqlReturnModel.getIsSuccess()) ? 1 : 0);
        returnJson.setErrorMsg(sqlReturnModel.getFailingReason());
        return returnJson.toString();
    }
}
